/*
 * FrmMain.java
 *
 * Created on 12 de Novembro de 2008, 14:59
 */
package org.jboleto.view;

import java.io.FileInputStream;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import org.jboleto.JBoleto;
import org.jboleto.JBoletoBean;
import org.jboleto.control.Generator;
import org.jboleto.control.PDFGenerator;

/**
 *
 * @author  wanderson
 */
public class FrmMain extends javax.swing.JFrame {

    /** Creates new form FrmMain */
    public FrmMain() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu01 = new javax.swing.JMenu();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuItem03 = new javax.swing.JMenuItem();
        jMenuItem04 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        jMenuItem5 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Geração de Boletos");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jMenu01.setText("Geração de Boletos");
        jMenu01.add(jSeparator1);

        jMenuItem03.setText("Gerar Boletos em Bloco - Banco do Brasil");
        jMenuItem03.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem03ActionPerformed(evt);
            }
        });
        jMenu01.add(jMenuItem03);

        jMenuItem04.setText("Gerar Boletos em Bloco - Caixa Econômica");
        jMenuItem04.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem04ActionPerformed(evt);
            }
        });
        jMenu01.add(jMenuItem04);
        jMenu01.add(jSeparator2);

        jMenuItem5.setText("Sobre");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu01.add(jMenuItem5);

        jMenuBar1.add(jMenu01);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 561, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 380, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        FrmSobre sobre = new FrmSobre();
        sobre.show(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem03ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem03ActionPerformed
        FrmGeraBoletoBlocoBB blocoBB = new FrmGeraBoletoBlocoBB();
        blocoBB.show(true);
        /*
        try {
            
            //-- Necessario para ler o Xml - Stax
            XMLInputFactory fInput = XMLInputFactory.newInstance();
            XMLStreamReader reader = fInput.createXMLStreamReader(new FileInputStream("/home/wanderson/NetBeansProjects/Stax/src/stax/contatos.xml"));
            //--
            
            
            JBoletoBean jBoletoBean = new JBoletoBean();

            jBoletoBean.setDataDocumento("23/10/2008");
            jBoletoBean.setDataProcessamento("23/10/2008");

            jBoletoBean.setCedente("CONSELHO REGIONAL DE ENGENHARIA DO RIO GRANDE DO NORTE");
            jBoletoBean.setCarteira("21");

            jBoletoBean.setNomeSacado("WANDERSON CÂMARA DOS SANTOS");
            jBoletoBean.setEnderecoSacado("Av. Senador Salgado Filho");
            jBoletoBean.setBairroSacado("Lagoa Nova");
            jBoletoBean.setCidadeSacado("Rio Grande do Norte");
            jBoletoBean.setUfSacado("RN");
            jBoletoBean.setCepSacado("59040-580");
            jBoletoBean.setCpfSacado("0000000000000");

            jBoletoBean.setLocalPagamento("ATE O VENCIMENTO, PREFERENCIALMENTE NO BANCO DO BRASIL");
            jBoletoBean.setLocalPagamento2("APOS O VENCIMENTO, SOMENTE NO BANCO DO BRASIL");

            Vector descricoes = new Vector();
            jBoletoBean.setDescricoes(descricoes);

            //jBoletoBean.setImagemMarketing("/home/wanderson/painel.png");

            jBoletoBean.setDataVencimento("23/10/2008");
            jBoletoBean.setInstrucao1("ANUIDADE PESSOA FÍSICA DO EXERCICIO - 2008");
            jBoletoBean.setInstrucao2("APOS O VENCIMENTO COBRAR R$ 0,50 POR DIA DE ATRASO");
            jBoletoBean.setInstrucao3("");
            jBoletoBean.setInstrucao4("");

            jBoletoBean.setAgencia("1668");
            jBoletoBean.setContaCorrente("00074123"); //completar com zeros quando necessario
            jBoletoBean.setDvContaCorrente("X");

            jBoletoBean.setNumConvenio("458799");
            jBoletoBean.setNossoNumero("8200305307", 17);
            jBoletoBean.setValorBoleto("180.00");

            Generator generator = new PDFGenerator(jBoletoBean, JBoleto.BANCO_DO_BRASIL);
            JBoleto jBoleto = new JBoleto(generator, jBoletoBean, JBoleto.BANCO_DO_BRASIL);

            for (int i = 0; i < 1000; i++) {
                jBoleto.addBoleto();
            }
            
            //jBoleto.closeBoleto("/home/wanderson/004BBCREA.pdf");
            jBoleto.closeBoleto("c:/004BBCREA.pdf");
        } catch (Exception exception) {
            JOptionPane.showMessageDialog(null, "Exception: " + exception.getMessage(), "Erro Ao Executar", JOptionPane.INFORMATION_MESSAGE);
        }
        */
                
}//GEN-LAST:event_jMenuItem03ActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        FrmMain frmMain = new FrmMain();
        frmMain.setTitle("Gerador de Boletos");
    }//GEN-LAST:event_formWindowActivated

    private void jMenuItem04ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem04ActionPerformed
       FrmGeraBoletoBlocoCAIXA blocoCAIXA = new FrmGeraBoletoBlocoCAIXA();
       blocoCAIXA.show(true);
    }//GEN-LAST:event_jMenuItem04ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmMain().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu01;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem03;
    private javax.swing.JMenuItem jMenuItem04;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    // End of variables declaration//GEN-END:variables
}
